package com.slipper.sfts.broker;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.slipper.sfts.api.broker.bo.BrokerBO;
import com.slipper.sfts.api.broker.service.IBrokerSv;
import com.slipper.system.common.Constants;
import com.slipper.common.util.ResultUtil;

/**
 * 券商信息表
 */
@RestController
@RequestMapping("/broker")
public class BrokerController {
    @Resource
    private IBrokerSv brokerSv;
    
    @PostMapping(value = "/queryBy")
    public String queryBy(@RequestBody BrokerBO bo) {
        if(bo.getId() == null || "".equals(bo.getId())) {
            return ResultUtil.toErrorJson("数据获取失败！");
        }
        return ResultUtil.toJson(brokerSv.queryBy(bo.getId()));
    }

    @PostMapping(value = "/queryList")
    public String queryList(@RequestBody BrokerBO bo) {
        return ResultUtil.toJson(brokerSv.queryList(bo));
    }
    
    @PostMapping(value = "/queryPage")
    public String queryPage(@RequestBody BrokerBO bo) {
        return ResultUtil.toJson(brokerSv.queryPage(bo));
    }

    @PostMapping(value = "/save")
    public String save(@RequestBody BrokerBO bo) {
        bo.setUpdateId(Constants.getCurrentUser().getEmployeeId());
        bo.setCreateId(Constants.getCurrentUser().getEmployeeId());
        return ResultUtil.toJson(brokerSv.save(bo));
    }

    @PostMapping(value = "/delete")
    public String delete(@RequestBody BrokerBO bo) {
        return ResultUtil.toJson(brokerSv.delete(bo));
    }
}
